//
//  Extension+NSAttributeString.swift
//  MyWeibo
//
//  Created by 黄勇锋 on 16/7/31.
//  Copyright © 2016年 黄勇锋. All rights reserved.
//

import UIKit


extension NSAttributedString{
    
    //便利构造函数
    convenience init(emoticon:HYFEmoticon,y:CGFloat,lineHeight:CGFloat) {
        
        //文本附件
        let att = HYFTextAttachment()
        // 赋值
        att.emoticon = emoticon
        //设置 image
        att.image = UIImage.getEmoticonImage(emoticon.path)
        //记住一定要设置 bounds
        att.bounds = CGRect(x: 0, y: y, width: lineHeight, height: lineHeight)
        
        self.init(attachment: att)
    }
    
    
    
}
